<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section class="flex flex-col gap-4" [formGroup]="photoCameraInputWidgetSettingsForm">
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.input-widgets.general-settings</div>
    <div class="tb-form-row space-between">
      <div class="fixed-title-width" translate>widgets.input-widgets.widget-title</div>
      <tb-string-pattern-autocomplete class="flex-1"
                                      brackets="curly"
                                      subscriptSizing="dynamic"
                                      predefinedValuesButton="true"
                                      appearance="outline"
                                      label="{{ 'widgets.input-widgets.widget-title' | translate }}"
                                      [predefinedValues]="predefinedValues"
                                      placeholderText="{{ 'widget-config.set' | translate }}"
                                      formControlName="widgetTitle"
      ></tb-string-pattern-autocomplete>
    </div>
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.input-widgets.save-image</div>
    <mat-slide-toggle class="mat-slide" formControlName="saveToGallery">
      {{ 'widgets.input-widgets.save-to-gallery' | translate }}
    </mat-slide-toggle>
    @if (photoCameraInputWidgetSettingsForm.get('saveToGallery').value) {
      <mat-slide-toggle class="mat-slide" formControlName="usePublicGalleryLink">
        {{ 'widgets.input-widgets.public-image' | translate }}
      </mat-slide-toggle>
    }
  </div>
  <div class="tb-form-panel">
    <div class="tb-form-panel-title" translate>widgets.input-widgets.image-settings</div>
    <div class="tb-form-row space-between">
      <div translate>widgets.input-widgets.image-format</div>
      <mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
        <mat-select formControlName="imageFormat">
          <mat-option [value]="'image/jpeg'">
            {{ 'widgets.input-widgets.image-format-jpeg' | translate }}
          </mat-option>
          <mat-option [value]="'image/png'">
            {{ 'widgets.input-widgets.image-format-png' | translate }}
          </mat-option>
          <mat-option [value]="'image/webp'">
            {{ 'widgets.input-widgets.image-format-webp' | translate }}
          </mat-option>
        </mat-select>
      </mat-form-field>
    </div>

    @if (photoCameraInputWidgetSettingsForm.get('imageFormat').value !== 'image/png') {
      <div class="tb-form-row space-between">
        <div translate>widgets.input-widgets.image-quality</div>
        <mat-form-field class="number" appearance="outline" subscriptSizing="dynamic">
          <input matInput type="number" min="0" max="100" formControlName="imageQuality">
          <span matSuffix>%</span>
        </mat-form-field>
      </div>
    }

    <div class="tb-form-row space-between column-xs">
      <div class="fixed-title-width !min-w-30">Size</div>
      <div class="flex flex-row items-center justify-star gap-2">
        <div class="tb-small-label" translate>widgets.input-widgets.max-image-width</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput type="number" min="1" formControlName="maxWidth">
          <span matSuffix>px</span>
        </mat-form-field>
        <mat-divider vertical class="xs:hidden"></mat-divider>
        <div class="tb-small-label" translate>widgets.input-widgets.max-image-height</div>
        <mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
          <input matInput type="number" min="1" formControlName="maxHeight">
          <span matSuffix>px</span>
        </mat-form-field>
      </div>
    </div>
  </div>
</section>
